import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import { defineAsyncComponent } from 'vue'
import layout from '@/layout/index.vue'

const routes: Array<RouteRecordRaw> = [
	{
		path: '/',
		name: 'microApp',
		component: layout,
		redirect: '/microApp',
		children: [
			{
				path: '/',
				name: 'microApp',
				component: defineAsyncComponent(() => import('@/views/microApp/index.vue')),
				meta: {
					title: '首页'
				}
			}
		]
	},
	{
		path: '/404',
		name: '404',
		component: defineAsyncComponent(() => import('@/views/errorPage/404.vue'))
	},
	{
		path: '/401',
		component: defineAsyncComponent(() => import('@/views/errorPage/401.vue'))
	},
	{
		path: '/:pathMatch(.*)',
		redirect: '/404',
		component: defineAsyncComponent(() => import('@/views/errorPage/401.vue')),
		children: []
	}
];

const router = createRouter({
	history: createWebHistory(`${import.meta.env.VITE_BASE_URL}`),
	routes,
});

export default router;
